{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Overwriting MNIST_Net.py\n"
     ]
    }
   ],
   "source": [
    "%%writefile MNIST_Net.py\n",
    "\n",
    "import torch\n",
    "import torch.nn as nn\n",
    "import pdb\n",
    "from torch.autograd import Variable\n",
    "class MNIST_Net(nn.Module):\n",
    "    def __init__(self,num_classes=10,hidden_size=256):\n",
    "        super(MNIST_Net, self).__init__()\n",
    "\n",
    "        self.classifier = nn.Sequential(\n",
    "           \n",
    "            nn.Linear( 28 * 28, hidden_size),\n",
    "            nn.ReLU(inplace=True),\n",
    "            nn.Linear(hidden_size, hidden_size),\n",
    "            nn.ReLU(inplace=True),\n",
    "            nn.Linear(hidden_size, num_classes))\n",
    "\n",
    "    def forward(self, x):\n",
    "        x = self.classifier(x)\n",
    "        return x\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Appending to MNIST_Net.py\n"
     ]
    }
   ],
   "source": [
    "%%writefile -a MNIST_Net.py\n",
    "\n",
    "import torch\n",
    "import torch.nn as nn\n",
    "import pdb\n",
    "from torch.autograd import Variable\n",
    "class MNIST_Net_buttelNeck(nn.Module):\n",
    "    def __init__(self,num_classes=10,hidden_size=256,buttel_neck=10):\n",
    "        super(MNIST_Net_buttelNeck, self).__init__()\n",
    "\n",
    "        self.classifier = nn.Sequential(\n",
    "           \n",
    "            nn.Linear( 28 * 28, hidden_size),\n",
    "            nn.ReLU(inplace=True),\n",
    "            nn.Linear(hidden_size, hidden_size),\n",
    "            nn.ReLU(inplace=True),\n",
    "            nn.Linear(hidden_size, buttel_neck),\n",
    "            nn.ReLU(inplace=True),\n",
    "            nn.Linear(buttel_neck, num_classes))\n",
    "\n",
    "    def forward(self, x):\n",
    "        x = self.classifier(x)\n",
    "        return x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from MNIST_Net import *\n",
    "mnist_net=MNIST_Net_buttelNeck(2,8,10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MNIST_Net_buttelNeck(\n",
       "  (classifier): Sequential(\n",
       "    (0): Linear(in_features=784, out_features=8)\n",
       "    (1): ReLU(inplace)\n",
       "    (2): Linear(in_features=8, out_features=8)\n",
       "    (3): ReLU(inplace)\n",
       "    (4): Linear(in_features=8, out_features=10)\n",
       "    (5): ReLU(inplace)\n",
       "    (6): Linear(in_features=10, out_features=2)\n",
       "  )\n",
       ")"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mnist_net\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "torch.save(mnist_net,'mnist_net_8_10_buttleNeck.pth.tar')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from MNIST_Net import *\n",
    "mnist_net=MNIST_Net_buttelNeck(2,256)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from MNIST_Net import *\n",
    "mnist_net=MNIST_Net(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from MNIST_Net import *\n",
    "mnist_net=MNIST_Net(2,128)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from MNIST_Net import *\n",
    "mnist_net=MNIST_Net(2,64)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from MNIST_Net import *\n",
    "mnist_net=MNIST_Net(2,32)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from MNIST_Net import *\n",
    "mnist_net=MNIST_Net(2,16)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from MNIST_Net import *\n",
    "mnist_net=MNIST_Net(2,8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "torch.save(mnist_net,'mnist_net_buttleNeck.pth.tar')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "torch.save(mnist_net,'mnist_net_8.pth.tar')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "torch.save(mnist_net,'mnist_net_16.pth.tar')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "torch.save(mnist_net,'mnist_net_32.pth.tar')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "torch.save(mnist_net,'mnist_net_64.pth.tar')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "torch.save(mnist_net,'mnist_net_128.pth.tar')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "torch.save(mnist_net,'mnist_net.pth.tar')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "torch.save(mnist_net,'mnist_net256.pth.tar')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MNIST_Net(\n",
       "  (classifier): Sequential(\n",
       "    (0): Linear(in_features=784, out_features=256)\n",
       "    (1): ReLU(inplace)\n",
       "    (2): Linear(in_features=256, out_features=256)\n",
       "    (3): ReLU(inplace)\n",
       "    (4): Linear(in_features=256, out_features=2)\n",
       "  )\n",
       ")"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mnist_net"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MNIST_Net(\n",
       "  (classifier): Sequential(\n",
       "    (0): Linear(in_features=784, out_features=256)\n",
       "    (1): ReLU(inplace)\n",
       "    (2): Linear(in_features=256, out_features=256)\n",
       "    (3): ReLU(inplace)\n",
       "    (4): Linear(in_features=256, out_features=2)\n",
       "  )\n",
       ")"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mnist_net"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
